<template>
	<view>
		<view v-if="shows">
			<navs></navs>
		</view>
		<banner :getdata="getdata"></banner>
		<matter :getdata="getdata"></matter>
		<buy :getdata="getdata"></buy>
	</view>
</template>

<script>
	import navs from './components/navs.vue'
	import matter from './components/matter.vue'
	import banner from './components/bnnner.vue'
	import buy from './components/buy.vue'
	
	// 引入tab栏切换仓库值
	import {mapState} from 'vuex';
	//引入tabdata 插件
	import tabdata from '../../http/tabdata.js'
	
	export default {
		data() {
			return {
				shows:false,
				getdata:[]  ,//通过id请求下来的id
				navinger:''  // 引入tab栏切换仓库值
			}
		},
		components:{
			navs,
			banner,
			matter,
			buy
		},
		methods: {
			//用id去请求数据
			getupload(id){
				let dbs = this.navinger
				tabdata(dbs,id).then(res=>{
					// console.log(res)
					this.getdata=res.data
					//顺便传值到仓库，把值传到购物车里面
					this.$store.commit('getdMit',this.getdata)
				}).catch(err=>{
					console.log(err)
				})
			},
			
			
			//监听页面滚动
			onPageScroll(e){
				let top = e.scrollTop
				if (top > 90) {
					this.shows = true
				} else {
					this.shows = false
				}
			}
		},
		onLoad(openid) {
			//用id去请求数据
			let id = openid.id
			this.getupload(id)
			console.log(this.navinger)
		},
		
		computed:{
			...mapState(['navs']),
			count(){
				console.log(this.navs.naving)
				this.navinger = this.navs.naving
			}
		}
	}
</script>

<style>

</style>
